﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lotto
{
    public partial class Form1 : Form
    {
        Lottery newLottery;
        public Form1()
        {
            InitializeComponent();
        }

        private void buttonCreateLotto_Click(object sender, EventArgs e)
        {
            lbShowGeneratedNumbers.Items.Clear();
            newLottery = new Lottery(int.Parse(textBoxMaxNumber.Text), int.Parse(textBoxNumOfNums.Text));
            ShowGameNumbersInArray(newLottery.storeLottoNum);
        }

        private void btnDrawNextNumber_Click(object sender, EventArgs e)
        {
            newLottery.Draw1Number();
            ShowUserNumbersInArray(newLottery.userLottoNum);
            

            if (newLottery.CheckIfYouWin())
            {
                MessageBox.Show("Great!!!");
            }
            else
            {
                MessageBox.Show("Try again");
            }
           
        }
        private void btnDrawAllNums_Click(object sender, EventArgs e)
        {
            newLottery.DrawAllNumbers();
            ShowUserNumbersInArray(newLottery.userLottoNum);

            if (newLottery.CheckIfYouWin())
            {
                MessageBox.Show("Great!!!");
            }
            else
            {
                MessageBox.Show("Try again");
            }
        }

        public void ShowGameNumbersInArray(int[] Object)
        {
            foreach (var item in Object)
            {
                //the method prits all numbers different than 0
                //there are no possible zeros to be drawn by the Draw() methods
                //the zeros are only the empty array elements
                if (item != 0)
                    lbShowGeneratedNumbers.Items.Add(item);
            }
        }

        public void ShowUserNumbersInArray(int[] Object)
        {
            lbShowUserNumbers.Items.Clear();
            foreach (var item in Object)
            {
                //the method prits all numbers different than 0
                //there are no possible zeros to be drawn by the Draw() methods
                //the zeros are only the empty array elements
                if (item != 0)
                    
                    lbShowUserNumbers.Items.Add(item);
                    
            }
        }
    }
}
